function Food(el) {
    this.el = el
    // 食物属性
    this.len = 20
    this.foodObj = null
    this.foodX = 0
    this.foodY = 0
}
Food.prototype.create = function () {
    // 创建div标签对象
    let divObj = document.createElement('div')
    // 设置食物样式
    divObj.style.width = this.len + 'px'
    divObj.style.height = this.len + 'px'
    divObj.style.background = 'black'
    divObj.style.position = 'absolute'
    this.foodObj = divObj
    // 页面展示 
    this.el.appendChild(divObj)
    // 调用移动
    this.move()

}
Food.prototype.move = function () {
    // 食物位置每次不一样 
    // console.log(this.el.style.width)
    // console.log(this.el.style.height)
    let foodXMaxNum = this.el.clientWidth / this.len - 1
    let foodYMaxNum = this.el.clientHeight / this.len - 1
    // 随机公式
    this.foodX = Math.floor(Math.random() * (foodXMaxNum - 0 + 1) + 0) * this.len
    this.foodY = Math.floor(Math.random() * (foodYMaxNum - 0 + 1) + 0) * this.len
    // console.log(this.foodX);
    // console.log(this.foodY);
    this.foodObj.style.left = this.foodX + 'px'
    this.foodObj.style.top = this.foodY + 'px'
}